home *** CD-ROM | disk | FTP | other *** search
- program AGE ;
- { By Peter Meiring, G0BSX. All rights Reserved. }
- { Version 1.0: }
- { This is a program will scan the Mail files and delete those older than }
- { a specified number of days. }
-
- { file format: MAIL files. }
- { From g0bsx@g0bsx.ampr.org Sun Jun 24 19:21:50 1990 }
- { Received: from g0bsx by g0bsx.ampr.org with SMTP }
- { id AA27765 ; Sun, 24 Jun 90 19:21:49 utc }
- { Date: Sun, 24 Jun 90 19:23:55 GMT }
- { Message-Id: <53@g0bsx.ampr.org> }
- { From: g0bsx@g0bsx.ampr.org (Peter Meiring) }
- { To: g0bsx%mac@g0bsx }
- { Subject: test 5 }
- { }
- { Message Text. }
-
- const
- Version = 'Version 1.0 (c) Peter Meiring, G0BSX, June 1990.';
- MAILDir = '\SPOOL\MAIL\';
- AreaFname = '\SPOOL\AREAS';
- tab = #$09;
- space = #$20;
-
- type WorkString = string[255];
- String40 = string[40];
-
- var
- FP : text;
- line : WorkString;
- w1,w2 : String40;
-
- function word( n : integer; s : WorkString) : string40;
-
- var c,p,q : integer;
- t,a : WorkString;
-
- begin
- t := s;
- for c := 1 to n do
- if length(t) > 0 then begin
- while (length(t) > 1) and ((t[1] = space)or(t[1] = Tab)) do
- t := copy( t, 2, length(t)-1);
- if (t = space) or (t = tab) then begin
- t := '';
- a := '';
- end;
- if t <> '' then
- p := pos( space, t);
- q := pos( tab, t);
- if ((p > q) and (q > 0)) or ((q > p) and (p = 0)) then p := q;
- if p <> 0 then begin
- a := copy( t, 1, p-1);
- t := copy( t, p+1, length(t) - p)
- end else begin
- a := t;
- t := ''
- end
- end;
- word := a
- end;
-
-
- procedure process(area, sdays : string40);
-
- var mailfp : text;
- outfp : text;
- age,n,y,m,d,a : integer;
- copying : boolean;
- line : workstring;
-
- function Now : integer ;
-
- type
- regpack = record
- ax,bx,cx,dx,bp,si,di,ds,es,flags: integer;
- end;
-
- var
- recpack: regpack; {assign record}
- ah,al,ch,cl,dh: byte;
- days,day,month,year : integer;
-
- begin
- ah := $2c; {initialize correct registers}
- with recpack do
- begin
- ax := $2a shl 8;
- end;
- MsDos(recpack); { call function }
- with recpack do
- begin
- year := cx;
- day := dx mod 256;
- month := dx shr 8;
- end;
- year := year-1990;
- days := year*365 + year div 4 + (275*month) div 9 - 2*((month+9) div 12 )
- + day - 30;
- if (year mod 4 = 0) and (month > 2) then days := succ(days);
- Now := days
- end;
-
- begin
- val(sdays,age,n);
- writeln('Current day: ',now);
- writeln('Aging bulletin area: ',area,'. Maximum age = ',age,' days.');
- assign(mailfp, MAILDir+area+'.TXT');
- {$I-}
- reset(mailfp);
- if IOResult <> 0 then begin
- writeln('Area empty');
- exit;
- end;
- {I+}
- assign(outfp, MAILDir+area+'.TMP');
- rewrite(outfp);
- copying := false;
- while not eof(mailfp) do begin
- readln(mailfp, line);
- if pos('From ',Line) = 1 then begin
- val(word(7,line),y,n);
- val(word(5,line),d,n);
- if pos('Jan',line)>0 then m := 1
- else if pos('Feb',line)>0 then m := 2
- else if pos('Mar',line)>0 then m := 3
- else if pos('Apr',line)>0 then m := 4
- else if pos('May',line)>0 then m := 5
- else if pos('Jun',line)>0 then m := 6
- else if pos('Jul',line)>0 then m := 7
- else if pos('Aug',line)>0 then m := 8
- else if pos('Sep',line)>0 then m := 9
- else if pos('Oct',line)>0 then m := 10
- else if pos('Nov',line)>0 then m := 11
- else if pos('Dec',line)>0 then m := 12;
- y := y-1990;
- a := y*365 + y div 4 + (275*m) div 9 - 2*((m+9) div 12 ) + d - 30;
- if (y mod 4 = 0) and (m > 2) then a := succ(a);
- write('Age ',a,' ',line);
- if now - a > age then begin
- copying := false;
- write(' - deleting');
- end
- else begin copying := true;
- writeln(' - copying')
- end
- end;
- if copying then writeln(outfp,line)
- end;
- close(outfp);
- erase(mailfp);
- rename(Outfp, MAILDir+area+'.TXT')
- end;
-
-
-
- begin
- writeln('G0BSX NOS mailbox bulletin areas maintenance program.');
- writeln(Version);
- assign(fp, AreaFName);
- {$I-}
- reset(fp);
- if IOResult <> 0 then begin
- writeln('*** Error accessing: ',AreaFName);
- halt
- end;
- {I+}
- while not EOF(fp) do begin
- readln(fp, line);
- if line <> '' then process( word(1,line), word(2,line));
- end
- end.